'use strict';

const Controller = require('egg').Controller;

// import { Controller } from 'egg'

class DetailController extends Controller {
  // 获取文章具体内容
  async getArticleDetail() {
    const { ctx, app } = this;
    const { id, update, author } = ctx.request.query;
    const res = await ctx.service.article.getArticleDetail(id, author, update);
    ctx.body = res;
  }

  // 增加文章点赞次数
  async addFavour() {
    const { ctx, app } = this;
    const res = await ctx.service.article.addFavour();
    ctx.body = res;
  }
  // 获取文章评论
  async getComments() {
    const { ctx, app } = this;
    let { articleId, userId, keyword, state, pageNum, pageSize } = ctx.request.query
    const res = await ctx.service.article.getComments(articleId, userId, keyword, state, pageNum, pageSize);
    ctx.body = res;
  }
  // 文章评论提交
  async comment() {
    const { ctx, app } = this;
    const res = await ctx.service.article.comment();
    ctx.body = res;
  }
  // 文章回复提交
  async reply() {
    const { ctx, app } = this;
    const res = await ctx.service.article.reply();
    ctx.body = res;
  }
  // 删除文章评论
  async deleteComment() {
    let { ctx} = this
    let res = await ctx.service.article.deleteComment()
    ctx.body = res
  }
}

module.exports = DetailController;
